use hypers::prelude::{hook, Next, Request, Responder, Response};
use crate::{COOKIE,COOKIE_NAME,WEB};

#[hook]
pub async fn global(req: &mut Request, next: &mut Next<'_>) -> impl Responder {
    let web = tera::Context::new();
    if let Some(v) = req.cookies().get(COOKIE_NAME) {
        req.set(COOKIE, v.value().to_owned());
    }
    req.set(WEB, web);
    next.next(req).await
}
